package com.Algorithm.Test;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2021/10/19/13:04
 * @Description: 包含n+1个整数的数组,数字在1-n之间,找重复数,不让用桶
 * @Target:
 */
public class searchRepeatNumTest {

    public static void main(String[] args) {
        int arr[] = new int[]{1,1,2};


        int repeatNum = 0;
        int i = 1;
        int p = 0;

        while (i<arr.length){
            repeatNum^=i++;
            repeatNum^=arr[p++];
        }
        repeatNum^=arr[arr.length-1];
        System.out.println(repeatNum);

    }



}
